<?php
session_start();
require_once "include/database.php";
$db = db_connect();
require_once "include/auth.php";
$current_user = current_user();
require_login();
require_user(1);
$title = "CS 4400 Project | Add Tutor";
include "_header.php"; 

$instructor_name_query = $db->prepare("SELECT Name FROM regular_user WHERE Username = :username");
$instructor_name_query->execute(array("username" => $current_user['Username']));
$instructor_name = $instructor_name_query->fetch();

$instructor_course_query = $db->prepare("SELECT DISTINCT Title from SectionComplete WHERE Instructor = :name");
$instructor_course_query->execute(array("name" => $instructor_name['Name']));
$instructor_course = $instructor_course_query->fetch();

$tutor_names_query = $db->prepare("SELECT ru.Name FROM regular_user AS ru
								WHERE ru.Username = ( 
									SELECT s.UsernameFROM student AS s
								WHERE s.Student_ID = 
								( SELECT app.Tutor_Student_ID FROM application_for_tutoring AS app
								WHERE app.Course_Title = 
								( SELECT DISTINCT sc.Title FROM SectionComplete AS sc
								WHERE sc.Title =  :course ) ) ) ");
$tutor_names_query->execute(array("course" => $instructor_course['Title'])); 


?>
<?php include "_footer.php" ?>